
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>$Title$</title>
</head>
<body>
<div>
  <table>
    <tr>
      <td>邮箱：</td>
      <td colspan="2">
        <input id="to" name="to"/>
        <input type="button" name="send" value="发送邮件" onclick="sendCode()" />
      </td>
    </tr>
    <tr>
      <td>验证码：</td>
      <td colspan="2">
        <input id="code" name="code" onblur="checkCode()"/>
        <span id="msgCode"></span>
      </td>
    </tr>
  </table>
</div>
</body>
<script src="js/jquery.js"></script>
<script>
  //发送验证码
  function sendCode() {
    $.get("SendMailServlet?to="+$("#to").val(),function (data) {
      if(data=="true"){
        alert("邮件已发送")
      }else {
        alert("邮件发送失败")
      }
    })
  }
  //检查验证码
  function checkCode() {
    $.get("CheckMailCodeServlet?code="+$("#code").val(),function (data) {
      if(data=="true"){
        $("#msgCode").html("✔")
      }else {
        $("#msgCode").html("✘")
      }
    })
  }
</script>
</html>
